#include "gridwidget.h"
#include "ui_gridwidget.h"
#include <QDebug>

GridWidget::GridWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GridWidget)
{
    ui->setupUi(this);
}

GridWidget::~GridWidget()
{
    delete ui;
}

void GridWidget::setValue( int _row, int _column, const QString _value )
{
    QWidget* wid = ui->gridLayout->itemAtPosition( _row, _column )->widget();
    QLineEdit* le = ( QLineEdit* )wid;
    le->setText( _value );
}

void GridWidget::setStyleSheet( int _row, int _column, const QString& _styleSheet )
{
    QWidget* wid = ui->gridLayout->itemAtPosition( _row, _column )->widget();
    QLineEdit* le = ( QLineEdit* )wid;
    le->setStyleSheet( _styleSheet );
}

void GridWidget::setLineEditReadOnly( int _row, int _column, bool _readonly )
{
    QWidget* wid = ui->gridLayout->itemAtPosition( _row, _column )->widget();
    QLineEdit* le = ( QLineEdit* )wid;
    le->setReadOnly( _readonly );
}

bool GridWidget::getLineEditReadOnly( int _row, int _column )
{
    QWidget* wid = ui->gridLayout->itemAtPosition( _row, _column )->widget();
    QLineEdit* le = ( QLineEdit* )wid;
    return le->isReadOnly();
}

int GridWidget::getLineEditValue( int _row, int _column )
{
    QWidget* wid = ui->gridLayout->itemAtPosition( _row, _column )->widget();
    QLineEdit* le = ( QLineEdit* )wid;
    return le->text().toInt();
}

